home *** CD-ROM | disk | FTP | other *** search
- USING OPENFILE
-
- ' Here's how to use the API's OpenFile function to access
- ' undocumented data and time stamp data.
-
- DefInt A-Z
-
- Declare Function OpenFile Lib "Kernel" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Integer) As Integer
-
- Global Const OF_EXIST = &H4000
- Global Const HFILE_ERROR = -1
-
- Type OFSTRUCT
- cBytes As String * 1 ' Length of structure
- fFixedDisk As String * 1 ' 0 if on removable disk
- nErrCode As Integer ' MS-DOS error code
- FileDate As String * 2 ' Reserved field
- FileTime As String * 2 ' Reserved field
- szPathName As String * 128 ' Complete pathname
- End Type
-
-
- Dim OFS As OFSTRUCT
-
- Sub Command1_Click ()
- FileName$ = Text1.Text
- OFS.cBytes = Chr$(Len(OFS))
- wStyle% = OF_EXIST
- Result% = OpenFile(FileName$, OFS, wStyle%)
- If Result% = HFILE_ERROR Then
- Beep
- MsgBox "Error: #" + Str$(OFS.nErrCode)
- Exit Sub
- End If
-
- ' Parse Time value
- TimeVal& = Asc(Right$(OFS.FileTime, 1)) * 256& + Asc(Left$(OFS.FileTime, 1))
- Sec% = (TimeVal& And &H1F) * 2
- Min% = (TimeVal& And &H7E0) \ &H20
- Hr% = (TimeVal& And &HF800) \ &H800
- TimeStr$ = Str$(Hr%) + ":" + Str$(Min%) + ":" + Str$(Sec%)
-
- ' Parse Date value
- DateVal& = Asc(Right$(OFS.FileDate, 1)) * 256& + Asc(Left$(OFS.FileDate, 1))
- D% = (DateVal& And &H1F)
- M% = (DateVal& And &H1E0) \ &H20
- Y% = (DateVal& And &HFE00) \ &H200
- DateStr$ = Str$(M%) + "/" + Str$(D%) + "/" + Str$(Y% + 1980)
-
- Text2.Text = TimeStr$ + " " + DateStr$
-
- End Sub
-